package com.yfp.operation.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.core.web.controller.BaseController;
import com.yfp.common.log.annotation.Log;
import com.yfp.common.log.enums.BusinessType;
import com.yfp.operation.domain.dto.PersonalOnlineStatusDTO;
import com.yfp.operation.domain.vo.PersonalOnlineStatusVO;
import com.yfp.operation.service.PersonalService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 个人中心操作接口
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/personal")
@Tag(name = "个人中心操作接口")
public class PersonalController extends BaseController {

    @Resource
    private PersonalService personalService;

    /**
     * 获取设备列表
     * 个人中心设备在线状态
     */
    @Operation(summary = "获取设备列表", description = "个人中心设备在线状态")
    @GetMapping("/machine/list")
    public R<List<PersonalOnlineStatusVO>> listState() {
        return R.ok(personalService.getListState());
    }

    @Operation(summary = "更新设备状态", description = "个人中心设备在线状态")
    @PutMapping("/machine/state")
    @Log(title = "更新代取设备运营状态", businessType = BusinessType.UPDATE)
    public R<Boolean> updateState(@Validated @RequestBody PersonalOnlineStatusDTO personalOnlineStatusDTO) {
        return R.ok(personalService.updateState(personalOnlineStatusDTO));
    }

    @Operation(summary = "删除运营人员关联设备", description = "yfp-tissue更新点位信息")
    @DeleteMapping("/machine/delete")
    public R<Void> delOperationUser(@RequestParam("operationUserId") Long operationUserId, @RequestParam("machines") List<String> machines) {
        personalService.delOperationUser(operationUserId, machines);
        return R.ok();
    }
}
